{{ $cover := .HasShortcode "blocks/cover" }}
<nav class="js-navbar-scroll navbar navbar-expand-xl navbar-dark {{ if $cover}} td-navbar-cover {{ end }} td-navbar">
    <a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
		<span class="navbar-logo"><img src="{{ .Site.Params.ui.navbar_logo  }}"></span>
	</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#main_navbar"
		aria-controls="main_navbar" aria-expanded="false" aria-label="Toggle navigation">
		<span class="navbar-toggler-icon"></span>
	</button>
	<div class="collapse navbar-collapse td-navbar-nav-scroll ml-md-auto" id="main_navbar">
		<ul class="navbar-nav mt-2 mt-lg-0 ml-auto">
			{{ $p := . }}
			{{ range .Site.Menus.main	 }}
			{{ if .HasChildren }}
			<li class="dropdown sub-menu{{if $p.HasMenuCurrent "main" . }} active{{end}}">
				<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					{{ .Pre }}
					<span>{{ .Name }}</span>
				</a>
				<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
					{{ range .Children }}
					<a class="dropdown-item" href="{{ .URL }}">{{ .Name }}</a>
					{{ end }}
				</div>
			</li>
			{{ else }}
			<li class="nav-item mr-4 mb-2 mb-lg-0">
				{{ $active := or ($p.IsMenuCurrent "main" .) ($p.HasMenuCurrent "main" .) }}
				{{ with .Page }}
				{{ $active = or $active ( $.IsDescendant .)  }}
				{{ end }}
				{{ $pre := .Pre }}
				{{ $post := .Post }}
				{{ $url := urls.Parse .URL }}
				{{ $baseurl := urls.Parse $.Site.Params.Baseurl }}
				<a class="nav-link{{if $active }} active{{end}}" href="{{ with .Page }}{{ .RelPermalink }}{{ else }}{{ .URL | relLangURL }}{{ end }}" {{ if ne $url.Host $baseurl.Host }}target="_blank" {{ end }}>{{ with .Pre}}{{ $pre }}{{ end }}<span{{if $active }} class="active"{{end}}>{{ .Name }}</span>{{ with .Post}}{{ $post }}{{ end }}</a>
			</li>
			{{ end }}
			{{ end }}
			{{ if  .Site.Params.versions }}
			<li class="nav-item dropdown mr-4">
				{{ partial "navbar-version-selector.html" . }}
			</li>
			{{ end }}
			{{ if  (gt (len .Site.Home.Translations) 0) }}
			<li class="nav-item dropdown mr-4">
				{{ partial "navbar-lang-selector.html" . }}
			</li>
			{{ end }}
		</ul>
	</div>
	<div class="navbar-nav d-none d-lg-block">{{ partial "search-input.html" . }}</div>
</nav>
